package cn.edu.jdbc;

import cn.edu.jdbc.util.DBUtil;
import cn.edu.jdbc.util.JdbcUtil;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 删除用户
 * delete from mydb01 where username='zhangjian';
 * delete from mydb01 where id = 3;
 */
public class JdbcDemo07 {

    public static void main(String[] args) {
        try {
            Connection conn = JdbcUtil.getConn();
            Statement st = conn.createStatement();
            String sql = "delete from mydb01 where username='lisi'";
            int rows = st.executeUpdate(sql);
            if (rows > 0 ){
                System.out.println("删除用户成功");
            } else {
                System.out.println("删除用户失败~");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

}
